Xbasic

WORD_IN_COMMON Function

Syntax

Common_List as C = word_in_common(C list1, C list2 [, C delimiter])

Arguments

list1Character

A list of words.

list2Character

A second list of words.

delimiterCharacter

Default = crlf(). The character string that delimits words in each list.

Returns

Common_ListLogical

Returns the words found in both lists, separated by the delimiter string.

Description

Find the words in common between two lists of words, ignoring case.

Discussion

Returns a list of words in common between List1 and List2, ignoring case. The words in List1 and List2 are separated by Delimiter. This function is typically used to find a list of words that two strings have in common.

The following Xbasic script defines two lists of CR-LF-delimited words, then finds the common words.

dim list1 as c =<<%a%
red
green
yellow
blue
purple
orange
%a%

dim list2 as c =<<%a%
red
orange
cyan
%a%

? word_in_common(list1, list2, crlf())
= red
orange

dim a as C = "one,two,three,four"
dim b as C = "two,four"

? word_in_common(a, b, ",")
= "two,four"

See Also